
//
//  WBDemoViewController.swift
//  SinaWebo
//
//  Created by 亚杏 on 2017/5/9.
//  Copyright © 2017年 oms. All rights reserved.
//

import UIKit

class WBDemoViewController: WBBaseViewController,UIGestureRecognizerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        //设置标题
        title = "第\(navigationController?.childViewControllers.count ?? 0)个"

        //设置子控制器全屏滑动，禁止只能侧边滑动
        let target = self.navigationController?.interactivePopGestureRecognizer!.delegate
        let pan = UIPanGestureRecognizer(target:target,
                                         action:Selector(("handleNavigationTransition:")))
        pan.delegate = self
        self.view.addGestureRecognizer(pan)
        //同时禁用系统原先的侧滑返回功能
        self.navigationController?.interactivePopGestureRecognizer!.isEnabled = false
        
    }

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer,
                           shouldRecognizeSimultaneouslyWith otherGestureRecognizer:
        UIGestureRecognizer) -> Bool {
        if self.childViewControllers.count == 1 {
            return false
        }
        return true
    }
    
    @objc private func showNext(){
        let vc = WBDemoViewController()
        navigationController?.pushViewController(vc, animated: true)
    }

    //重写父类方法
    override func setupTableView() {
        super.setupTableView()

        navItem.rightBarButtonItem = UIBarButtonItem(title: "下一步", target: self, action: #selector(showNext))
    }



}
